package com.sdehualu.spark

import com.sdehualu.utils.NetCDFUtils
import ucar.nc2.NetcdfFile

/**
 * @Author: 吴敬超
 * @Date: 2021/7/25 14:35
 */
object tes2 {


  def main(args: Array[String]): Unit = {

//    val ncf = NetCDFUtils.loadDFSNetCDFDataSet("hdfs://192.168.22.9:8020",
//      "/par0/B.E.13.B1850C5.ne120_t12.sehires38.003.sunway_02.rtm.h0.0022-02.nc",
//      4096, false)

    val filename = "D:/nc2json/data.nc"
    var ncf = NetcdfFile.open(filename)

    val csvvar = ncf.findVariable("lon")

    //    转换的数据转成object 形式的array
    val csvvarread = csvvar.read().copyToNDJavaArray()
    val float1 = csvvarread.asInstanceOf[Array[Float]]

    println(float1(0))

    println(float1.length)



    val csvvar2 = ncf.findVariable("U")

    //    转换的数据转成object 形式的array
    val csvvarread2 = csvvar2.read().copyToNDJavaArray()

    val float2 = csvvar2.read.copyToNDJavaArray.asInstanceOf[Array[Array[Array[Float]]]]

    println(float2(0)(0)(0))

    println(float2.length)

  }
}
